home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 676-700 / 691 / cmanual / ace2.lha / Intuition / Graphics / Example3.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  5KB  |  130 lines

  1. /***********************************************************/
  2. /*                                                         */
  3. /* Amiga C Encyclopedia (ACE) V3.0      Amiga C Club (ACC) */
  4. /* -------------------------------      ------------------ */
  5. /*                                                         */
  6. /* Book:    ACM Intuition               Amiga C Club       */
  7. /* Chapter: Graphics                    Tulevagen 22       */
  8. /* File:    Example3.c                  181 41  LIDINGO    */
  9. /* Author:  Anders Bjerin               SWEDEN             */
  10. /* Date:    92-05-01                                       */
  11. /* Version: 1.10                                           */
  12. /*                                                         */
  13. /*   Copyright 1992, Anders Bjerin - Amiga C Club (ACC)    */
  14. /*                                                         */
  15. /* Registered members may use this program freely in their */
  16. /*     own commercial/noncommercial programs/articles.     */
  17. /*                                                         */
  18. /***********************************************************/
  19.  
  20. /* This program will open a normal window which is connected to the */
  21. /* Workbench Screen. We will then print a text string with help of  */
  22. /* Intuition's IntuiText structure.                                 */
  23.  
  24.  
  25.  
  26. /* If your program is using Intuition you should include intuition.h: */
  27. #include <intuition/intuition.h>
  28.  
  29.  
  30.  
  31. struct IntuitionBase *IntuitionBase;
  32.  
  33.  
  34.  
  35. /* Declare a pointer to a Window structure: */ 
  36. struct Window *my_window;
  37.  
  38. /* Declare and initialize your NewWindow structure: */
  39. struct NewWindow my_new_window=
  40. {
  41.   40,            /* LeftEdge    x position of the window. */
  42.   20,            /* TopEdge     y positio of the window. */
  43.   400,           /* Width       400 pixels wide. */
  44.   150,           /* Height      150 lines high. */
  45.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  46.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  47.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  48.   SMART_REFRESH| /* Flags       Intuition should refresh the window. */
  49.   WINDOWDRAG|    /*             Drag gadget. */
  50.   WINDOWDEPTH|   /*             Depth arrange Gadgets. */
  51.   ACTIVATE,      /*             The window should be Active when opened. */
  52.   NULL,          /* FirstGadget No Custom Gadgets. */
  53.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  54.   "TEXT",        /* Title       Title of the window. */
  55.   NULL,          /* Screen      Connected to the Workbench Screen. */
  56.   NULL,          /* BitMap      No Custom BitMap. */
  57.   0,             /* MinWidth    We do not need to care about these */
  58.   0,             /* MinHeight   since we have not supplied the window */
  59.   0,             /* MaxWidth    with a Sizing Gadget. */
  60.   0,             /* MaxHeight */
  61.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  62. };
  63.  
  64.  
  65.  
  66. UBYTE my_text[]="This is the text that will be printed!";
  67.  
  68. struct IntuiText my_intui_text=
  69. {
  70.   1,         /* FrontPen, colour register 1. */
  71.   2,         /* BackPen, colour register 2. */
  72.   JAM2,      /* DrawMode, draw the characters with colour 1, on a colour */
  73.              /* 2 background. (White text on a black background) */ 
  74.   10, 20,    /* LeftEdge, TopEdge. */
  75.   NULL,      /* ITextFont, use default font. */
  76.   my_text,   /* IText, the text that will be printed. */
  77.              /* (Remember my_text = &my_text[0].) */
  78.   NULL,      /* NextText, no other IntuiText structures are connected. */
  79. };
  80.  
  81.  
  82.  
  83. main()
  84. {
  85.   /* Open the Intuition Library: */
  86.   IntuitionBase = (struct IntuitionBase *)
  87.     OpenLibrary( "intuition.library", 0 );
  88.   
  89.   if( IntuitionBase == NULL )
  90.     exit(); /* Could NOT open the Intuition Library! */
  91.  
  92.  
  93.  
  94.   /* We will now try to open the window: */
  95.   my_window = (struct Window *) OpenWindow( &my_new_window );
  96.   
  97.   /* Have we opened the window succesfully? */
  98.   if(my_window == NULL)
  99.   {
  100.     /* Could NOT open the Window! */
  101.     
  102.     /* Close the Intuition Library since we have opened it: */
  103.     CloseLibrary( IntuitionBase );
  104.  
  105.     exit();  
  106.   }
  107.  
  108.  
  109.  
  110.   /* Tell Intuition to print the text: */
  111.   PrintIText( my_window->RPort, &my_intui_text, 0, 0 );
  112.  
  113.  
  114.  
  115.   /* We have opened the window, and everything seems to be OK. */
  116.   /* Wait for 30 seconds: */
  117.   Delay( 50 * 30);
  118.  
  119.  
  120.  
  121.   /* We should always close the windows we have opened before we leave: */
  122.   CloseWindow( my_window );
  123.  
  124.  
  125.   
  126.   /* Close the Intuition Library since we have opened it: */
  127.   CloseLibrary( IntuitionBase );
  128.   
  129.   /* THE END */
  130. }